﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nina.Codec
{
    /// <summary>
    /// Abstract class for implementing data processing codecs
    /// </summary>
    public abstract class NinaCodec
    {
        /// <summary>
        /// Called when a session is started
        /// </summary>
        /// <param name="session">The session which has opened</param>
        public abstract void OnSessionStarted(NinaSession session);

        /// <summary>
        /// Called when a session is closed
        /// </summary>
        /// <param name="session">The session which has closed</param>
        public abstract void OnSessionClosed(NinaSession session);

        /// <summary>
        /// Called when data is read from a socket
        /// </summary>
        /// <param name="session">The associated session</param>
        /// <param name="data">The data to be processed</param>
        /// <param name="remaining">Any remaining bytes</param>
        /// <returns>True if a full packet was read</returns>
        public abstract bool OnRead(NinaSession session, ref byte[] data, ref byte [] remaining);

        /// <summary>
        /// Called when data is being written
        /// </summary>
        /// <param name="session">The associated session</param>
        /// <param name="data">The data to be processed</param>
        /// <returns>The data post-processing</returns>
        public abstract byte[] OnWrite(NinaSession session, byte[] data);
    }
}
